package 分库分表;

import java.util.Objects;

/**
 * @author 翟晓龙
 * @date 2022/3/31
 */
public class ShardCfg {

    /**
     * 库
     */
    Integer dbIdx;
    /**
     *  表
     */
    Integer tblIdx;

    Integer hash;

    public ShardCfg(Integer dbIdx,Integer tblIdx){
        this.dbIdx = dbIdx;
        this.tblIdx = tblIdx;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ShardCfg shardCfg = (ShardCfg) o;
        return Objects.equals(dbIdx, shardCfg.dbIdx) && Objects.equals(tblIdx, shardCfg.tblIdx) && Objects.equals(hash, shardCfg.hash);
    }

    @Override
    public int hashCode() {
        return Objects.hash(dbIdx, tblIdx, hash);
    }

    public Integer getDbIdx() {
        return dbIdx;
    }

    public void setDbIdx(Integer dbIdx) {
        this.dbIdx = dbIdx;
    }

    public void setHash(Integer hash) {
        this.hash = hash;
    }

    public Integer getHash() {
        return hash;
    }

    public Integer getTblIdx() {
        return tblIdx;
    }

    @Override
    public String toString() {
        return "ShardCfg{" +
                "dbIdx=" + dbIdx +
                ", tblIdx=" + tblIdx +
                ", hash=" + hash +
                '}';
    }
}
